//
//  UserInfoCell.swift
//  TCMHealth
//
//  Created by 韩颖 on 2023/7/2.
//

import UIKit

class UserInfoCell: UITableViewCell {

    @IBOutlet weak var bgView: UIView!
    @IBOutlet weak var userNameLable: UILabel!
    @IBOutlet weak var desLabel: UILabel!
    @IBOutlet weak var userImageView: UIImageView!
    var userInfo: UserInfo? {
        set {
            userNameLable.text = newValue?.name
            let imageName = (newValue?.gender == "0") ? "malePatients":"famalePatients"
            userImageView.image = UIImage.init(named: imageName)
            let desDic = newValue?.userDes.first
            let desStr = ((desDic as? [String:Any])?["diseaseDes"] as? String) ?? ""
            desLabel.text = desStr
        }
        
        get {
            return self.userInfo
        }
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        self.selectionStyle = .gray
    }
    
    

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        if (selected) {
            self.bgView.backgroundColor = UIColor.init(hex: "0xececec")
            self.bgView.layer.borderColor = UIColor.red.cgColor
            self.bgView.layer.borderWidth = 2
        }else {
            self.bgView.backgroundColor = .white
            self.bgView.layer.borderColor = nil
            self.bgView.layer.borderWidth = 0
        }
    }
    
}
